package control;

import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.HBox;
import javafx.scene.text.Font;
import javafx.stage.PopupWindow.AnchorLocation;
import javafx.stage.Stage;

// 提示条
public class TooltipDemo extends Application{
	private HBox root = new HBox(50);
	private Button button;
	private Tooltip tooltip;
	
	public static void main(String[] args) {
		launch(args);
	}
	
	@Override
	public void start(Stage stage) throws Exception {
		
		root.setAlignment(Pos.CENTER);
		
		// 提示条1
		tooltip = new Tooltip("这是提示条");
		tooltip.setFont(new Font(15));
		tooltip.setWrapText(true);		// 可换行
		tooltip.setAnchorLocation(AnchorLocation.CONTENT_TOP_RIGHT);	// 设置提示条位置(鼠标在的内容的右上方)
		tooltip.setStyle("-fx-background-color: pink; -fx-text-fill: white"); 
		tooltip.setPrefSize(70, 70);
		
		button = new Button("good");
		button.setTooltip(tooltip);
		root.getChildren().addAll(button);
		
		Scene scene = new Scene(root, 400, 200);
		stage.setScene(scene);
		stage.show();
	}
}
